Skip to content

Devid per client#406

Open
bigbrett wants to merge 1 commit into
wolfSSL:mainfrom
bigbrett:devid-per-client
Open

Devid per client#406
bigbrett wants to merge 1 commit into
wolfSSL:mainfrom
bigbrett:devid-per-client

Conversation

@bigbrett

@bigbrett bigbrett commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Overview:

This PR gives each client its own device ID, so you can run several clients in one process. You set a client's ID in its config (leave it 0 to get the default), and pass WH_CLIENT_DEVID(c) or the raw devId itself to wolfCrypt. The old shared IDs still work if you only have one client. DMA is now a simple per-client on/off switch instead of a separate device ID.

Changes:

  • Each client gets its own device ID, set in its config (0 means use the default). Read it back with WH_CLIENT_DEVID(c).
  • The old shared IDs (WH_DEV_ID, WH_DEV_ID_DMA) still work, but only with one client per process. You can now override their values at compile time.
  • Turn DMA on or off per client with wh_Client_SetDmaMode(). When it's on, calls that can't use DMA fall back to the normal path automatically.
  • Init and cleanup are safer with multiple clients: bad client IDs are rejected up front, a failed init undoes only its own work, and one client shutting down no longer affects the others.
  • Updated tests, benchmarks, examples, and docs to match the new devId scheme. The legacy global devIds are exercised via the wolfCrypt test suite.

Copilot AI review requested due to automatic review settings June 11, 2026 17:52

This comment was marked as outdated.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #406

Scan targets checked: none
Failed targets: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

⚠️ Review incomplete — one or more scan targets failed before findings could be produced. See the Fenrir PR review detail page for logs.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #406

Scan targets checked: none
Failed targets: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

⚠️ Review incomplete — one or more scan targets failed before findings could be produced. See the Fenrir PR review detail page for logs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 47 out of 47 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (2)

wolfhsm/wh_client.h:1

  • The docstring claims wh_Client_SetDmaMode() can return WH_ERROR_BADARGS on invalid input, but the implementation only errors on c == NULL and treats any non-zero useDma as enabled. Either (a) tighten the documentation to match current behavior (only NULL pointer is invalid), or (b) add explicit validation (e.g., only accept 0/1) so the documented error case is real.
    wolfhsm/wh_keyid.h:1
  • This comment describes client_id as always constrained to [1, WH_CLIENT_ID_MAX] (0 reserved), but then implies the server only rejects 0 when WOLFHSM_CFG_GLOBAL_KEYS is enabled. Given wh_Client_Init() now rejects 0 unconditionally, consider aligning the server-side contract/documentation by either (a) stating explicitly that the client library enforces 0 as invalid regardless of server config, or (b) updating the server INIT handling to reject 0 in all builds so the reserved namespace is consistently enforced end-to-end.

Comment thread src/wh_client.c Outdated
Comment thread src/wh_client.c
Comment thread src/wh_client.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #406

Scan targets checked: none
Failed targets: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

⚠️ Review incomplete — one or more scan targets failed before findings could be produced. See the Fenrir PR review detail page for logs.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #406

Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/wh_client.c Outdated
Comment thread src/wh_client.c Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.

Comment thread src/wh_client.c
Comment thread src/wh_client.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #406

Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

No new issues found in the changed files. ✅

@bigbrett bigbrett marked this pull request as ready for review June 15, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants